/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author YDZ
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';
import { UploadApiResult } from './upload';
import { UploadFileParams } from '/#/axios';

const { ctxPath, adminPath } = useGlobSetting();

export interface BasOperator extends BasicModel<BasOperator> {
  code?: string; // 操作工编码
  name?: string; // 操作工名称
  workShopCode?: string; // 归属车间
  buser?: string; // 是否用户
  userCode?: string; // 用户编码
  inDate?: string; // 入职日期
  iphone?: string; // 联系电话
  overDate?: string; // 离职日期
  carno?: string; // 证件号码
}

export const basOperatorList = (params?: BasOperator | any) =>
  defHttp.get<BasOperator>({ url: adminPath + '/bas/mes/operator/basOperator/list', params });

export const basOperatorListData = (params?: BasOperator | any) =>
  defHttp.post<Page<BasOperator>>({
    url: adminPath + '/bas/mes/operator/basOperator/listData',
    params,
  });

export const basOperatorForm = (params?: BasOperator | any) =>
  defHttp.get<BasOperator>({ url: adminPath + '/bas/mes/operator/basOperator/form', params });

export const basOperatorSave = (params?: any, data?: BasOperator | any) =>
  defHttp.postJson<BasOperator>({
    url: adminPath + '/bas/mes/operator/basOperator/save',
    params,
    data,
  });

export const basOperatorDisable = (params?: BasOperator | any) =>
  defHttp.get<BasOperator>({ url: adminPath + '/bas/mes/operator/basOperator/disable', params });

export const basOperatorEnable = (params?: BasOperator | any) =>
  defHttp.get<BasOperator>({ url: adminPath + '/bas/mes/operator/basOperator/enable', params });

export const basOperatorDelete = (params?: BasOperator | any) =>
  defHttp.get<BasOperator>({ url: adminPath + '/bas/mes/operator/basOperator/delete', params });

export const basOperatorTreeData = (params?: BasOperator | any) =>
  defHttp.post<Page<BasOperator>>({
    url: adminPath + '/bas/mes/operator/basOperator/treeData',
    params,
  });

export const basOperatorImportData = (
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: ctxPath + adminPath + '/bas/mes/operator/basOperator/importData',
      onUploadProgress,
    },
    params,
  );
